﻿@using Model;
@{
    SiteSecurity.RequireAuthenticatedUser();

    if (Roles.IsUserInRole(UsersRoles.Admin))
    {
        Layout = "~/Admin/_AdminSiteLayout.cshtml";
    }
    else
    {
        Layout = "~/Shared/_SiteLayout.cshtml";
    }

    Page.Title = "Profile";

    Profile aProfile = null;
    if (!IsPost)
    {
        aProfile = SiteHelper.GetMyProfile();
        if (aProfile == null)
        {
            aProfile = new Profile();
        }
    }

    if (IsPost)
    {
        Response.Redirect("~/Account/ProfileEdit");
    }
}
<fieldset>
    <legend>My Profile</legend>
    <div>
        <div class="divwrapper" style="float: left;">
            <table class="table">
                <tbody>
                    <tr>
                        <td class="user-info-label">
                            Name
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            @aProfile.FirstName
                        </td>
                    </tr>
                    <tr>
                        <td class="user-info-label">
                            Father's Name
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            @aProfile.FathersName
                        </td>
                    </tr>
                    <tr>
                        <td class="user-info-label">
                            Mother's Name
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            @aProfile.MothersName
                        </td>
                    </tr>
                    <tr>
                        <td class="user-info-label">
                            Village
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            @aProfile.AddressLine1 , @aProfile.AddressLine2
                        </td>
                    </tr>
                    <tr>
                        <td class="user-info-label">
                            Birth Day
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            @aProfile.BirthDate
                        </td>
                    </tr>
                    @if (!Roles.IsUserInRole(UsersRoles.Admin))
                    {
                        <tr>
                            <td class="user-info-label">
                                Class
                            </td>
                            <td>
                                :
                            </td>
                            <td class="user-info">
                                @aProfile.ReadingClass
                            </td>
                        </tr>
                        <tr>
                            <td class="user-info-label">
                                School
                            </td>
                            <td>
                                :
                            </td>
                            <td class="user-info">
                                My School
                            </td>
                        </tr>
                        <tr>
                            <td class="user-info-label">
                                Group
                            </td>
                            <td>
                                :
                            </td>
                            <td class="user-info">
                                @aProfile.ReadingGroup
                            </td>
                        </tr>
                    }
                    <tr>
                        <td class="user-info-label">
                            Mobile
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            @aProfile.Mobile
                        </td>
                    </tr>
                    <tr>
                        <td class="user-info-label">
                            Email
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            @aProfile.Email
                        </td>
                    </tr>
                    <tr>
                        <td class="user-info-label">
                            Facebook
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            <a href="http://www.facebook.com/@aProfile.FbUserName" target="_blank">@aProfile.FbUserName</a>
                        </td>
                    </tr>
                    <tr>
                        <td class="user-info-label">
                            Twitter
                        </td>
                        <td>
                            :
                        </td>
                        <td class="user-info">
                            <a href="http://www.twitter.com/@aProfile.TwitterUserName" target="_blank">@aProfile.TwitterUserName</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a class="button medium green"  href="@Href("~/Account/ChangePassword")">Change Password</a>
                        </td>
                        <td>
                        </td>
                        <td>
                            <p class="form-actions">
                                <a class="button medium green" href="@Href("~/Account/ProfileEdit")">Edit Profile</a>
                            </p>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="divwrapper" style="margin: 0 0 0 10px; float: left;">
            <table>
                <tbody>
                    <tr>
                        <td>
                            @if (!aProfile.FbUserName.IsEmpty())
                            {
                                string FbUserName = " http://www.facebook.com/" + aProfile.FbUserName;
                                @Facebook.LikeButton(href: @FbUserName)
                            }
                        </td>
                        <td>
                            @if (!aProfile.TwitterUserName.IsEmpty())
                            {
                                @Twitter.Profile(@aProfile.TwitterUserName)
                            }
                        </td>
                        <td>
                            @if (!aProfile.FirstName.IsEmpty())
                            {
                                @Twitter.Search(@aProfile.FirstName)
                            }
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</fieldset>